/*
 *  damage.cpp
 *  EPPI-0.0
 *
 *  Created by Cesar Polindara on 9/7/13.
 *  Copyright 2007 __MyCompanyName__. All rights reserved.
 *
 */

#include "damage.h"

Damage::Damage()
:	Material(),
	matHyper()
{}

// ***

Damage::Damage(ifstream &in, const string& na, const string & t, Material* ma)
:	Material(na,t),
	matHyper(ma)
{
	int i,j;
	string keyword;
	
//	while (in >> keyword && keyword.compare("ENDMATERIAL") )
//	{
//	if(!keyword.compare("EXPASION"))
//        {
//			in >> a;
//        }
//    	}

    hypertype = matHyper->hypertype;

    density = matHyper->density;

    // cout << "matHyper: " << matHyper->type << endl;
}       

// ***

void Damage::calcW( const VectorXd & C , const double & k )
{
        // Compute W for the base material... note that when you use
        // calc you don't get a return.
	matHyper->calcW(C); // Here the invariants are computed for C
	
        // When string found compare returns 1 >>> But 1:False
        // When string not found compare returns 0  >>> But 0:True
	if(!matHyper->hypertype.compare("coupled"))
    {
		W = matHyper->getW();
    }
    // Whe is couple
    else
    {
    	W = matHyper->getW();
    }
}

// ***

void Damage::calcS( const VectorXd & C, const double & k )
{
	matHyper->calcS(C);
	
	if(!matHyper->hypertype.compare("coupled"))
    {
		S = matHyper->getS();
    }
	else
	{
		S = matHyper->getS();
	}

	// cout << "S= " << endl << S << endl;
}

// ***

void Damage::calcCt( const VectorXd & C, const double & k)
{

	// First compute the base tangent modulus
	matHyper->calcCt(C);
	
	// InverserVoigtFormat(CtTens, Ct);

	// Now add the remaining stuff
	if (!matHyper->hypertype.compare("coupled"))
	{
	//dyadic(Tensor2Sym,Tensor2Sym)
	//doubleContraction()
	//selfDyadic()
 		Ct = matHyper->getCt();
 		// CtTens(i,j) = Ct(0,0) + 1.0;
	}
	else
	{
		Ct = matHyper->getCt();
	}
	
	//cout << "Ct= " << endl << Ct << endl;

	//VoigtFormat(S,STens);
	//VoigtFormat(Ct,CtTens);
}

// ***
